/*
  文章列表模块
*/
import request from '@/utils/request.js'

// 获取文章列表数据
export const loadArticleList = (params) => {
  return request({
    method: 'get',
    url: 'articles',
    params: params
  })
}

// 获取频道列表
export const loadChannelList = () => {
  return request({
    method: 'get',
    url: 'channels'
  })
}

// 删除文章 接口模块
export const deleteArticle = (id) => {
  return request({
    method: 'delete',
    url: 'articles/' + id
  })
}

// 发布文章
export const publishArticle = (data, query) => {
  return request({
    method: 'post',
    url: 'articles',
    // data 请求体
    data: data,
    // query
    params: query
  })
}
// 根据id获取文章详情数据
export const getArticleInfo = (id) => {
  return request({
    method: 'get',
    url: 'articles/' + id
  })
}
// 编辑文章
export const editArticle = (data, query) => {
  const {
    id,
    ...other
  } = data
  return request({
    method: 'put',
    url: 'articles/' + id,
    data: other,
    params: query
  })
}
